package servlet;

import bean.dianzan;
import net.sf.json.JSONObject;
import service.dianzanService;
import service.impl.dianzanServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(urlPatterns= "/toSelect")
public class selectServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String str = req.getParameter("id");
        int id = Integer.parseInt(str);
        dianzan initAr = new dianzan();
        initAr.setId(id);
        dianzanService service = new dianzanServiceImpl();
        dianzan ar = service.select(initAr);
        JSONObject jo = JSONObject.fromObject(ar);
        resp.setContentType("text/html;charset=utf-8");
        PrintWriter out = resp.getWriter();
        out.print(jo);

    }
}
